<template>
  <div>
    <el-container>
      <el-header>
        <div class="headerConfig">
          <div class="headerLeft">校园帮忙管理后台</div>
          <div class="headerRight">
            <p>hello：{{ getAdmin }}</p>
            <el-button @click="logout">退出</el-button>
          </div>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-col :span="24">
            <h5 class="menuTitle">管理菜单</h5>
            <el-menu
              default-active="Admin"
              class="el-menu-vertical- demo"
              @select="selectMenu"
            >
              <el-menu-item index="Admin">
                <i class="el-icon-menu"></i>
                <span slot="title">管理员管理</span>
              </el-menu-item>
              <el-menu-item index="Order">
                <i class="el-icon-document"></i>
                <span slot="title">订单管理</span>
              </el-menu-item>
              <el-menu-item index="Total">
                <i class="el-icon-setting"></i>
                <span slot="title">数据统计</span>
              </el-menu-item>
            </el-menu>
          </el-col>
        </el-aside>
        <el-container>
        <el-main>
            <router-view></router-view>
        </el-main>
          <el-footer>版本v1.0</el-footer>
        </el-container>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  computed: {
    getAdmin() {
      const admin = localStorage.getItem("admin");
      if (admin) {
        const { nickName } = JSON.parse(localStorage.getItem("admin"));
        if (nickName) {
          return nickName;
        } else {
          this.$router.push({
            name: "Login",
          });
        }
      } else {
        this.$router.push({
          name: "Login",
        });
      }
    },
  },
methods: {
    logout() {
        localStorage.removeItem("admin");
        this.$router.push({
            name: "Login",
        });
    },
    selectMenu(key,keyPath){
        // console.log(key,keyPath)
        this.$router.push({
            name:key
        })
    }
    },
};
</script>
<style lang="scss" scoped>
.body {
    height: 100vh;
    .el-header {
        background: linear-gradient(
            to right,
            rgb(107, 151, 247),
            rgb(255, 255, 255)
        );  
    .headerConfig {
        display: flex;
        align-items: center;
        justify-content: space-between;
            .headerLeft {
            color: #fff;
            font-size: 20px;
            font-weight: bold;
        }
        .headerRight {
            display: flex;
            align-items: center;
        p {
            margin-right: 20px;
        }
        .el-button {
            height: 40px;
        }
        }
    }
    }
}
.el-footer {
    background-color: #b3c0d1;
    color: #333;
    text-align: center;
    line-height: 60px;
}
.el-main {
    background-color: #e9eef3;
    color: #333;
    text-align: center;
    line-height: 160px;
}
//修改.el-aside如下
.el-aside {
    background-color: #fff;
    color: #333;
    text-align: center;
    border-right: 1px solid #b3c0d1;
}
//增加.el-menu
.el-menu {
    border: none;
}
.menuTitle{
    font-size: 20px;
    margin:0;
    background-color: #aec5e4;
    padding:20px 0;
}
</style>